package com.yunbao.project.basedata.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yunbao.project.basedata.entity.Storage;
import com.yunbao.project.basedata.mapper.StorageMapper;
import com.yunbao.project.basedata.query.StorageQuery;
import com.yunbao.project.basedata.service.IStorageService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 仓库 服务实现类
 * </p>
 *
 * @author 安能
 * @since 2019-09-16
 */
@Service
public class StorageServiceImpl extends ServiceImpl<StorageMapper, Storage> implements IStorageService {


    @Resource
    StorageMapper storageMapper;

    @Override
    public IPage<Storage> getListLike(StorageQuery storage) {


        Page<Storage> page = new Page<>(storage.getCurrent(), storage.getSize());

        return storageMapper.selectPage(page, new QueryWrapper<Storage>()
                .like("serial_number", storage.getSerialNumber())
                .or()
                .like("name", storage.getName())
                .or()
                .like("contacts", storage.getContacts())
                .or()
                .like("phone", storage.getPhone())
        );
    }
}
